package ua.dp.md05;

import org.hibernate.validator.constraints.NotEmpty;
import ua.dp.md05.common.AbstractEntity;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import java.util.Date;

@Entity
public class Comment extends AbstractEntity {

	private static final long serialVersionUID = 1L;

	@NotNull
	@ManyToOne(optional = false)
	private User author;

	@NotNull
	@ManyToOne(optional = false)
	private Product product;

	@Lob
	@NotEmpty
	private String content;

	@NotNull
	@Temporal(TemporalType.TIMESTAMP)
	private Date created = new Date();

	public User getAuthor() {
		return author;
	}

	public void setAuthor(User author) {
		this.author = author;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Date getCreated() {
		return created;
	}

}
